<?php
declare(strict_types=1);

use SixShop\Message\Controller\Api\{
    AnnouncementController,
    NotificationController,
    PrivateMessageController,
    MessageSettingController,
    MessageController,
};
use SixShop\System\Middleware\MacroPageMiddleware;
use think\facade\Route;

// API路由
// 路由前缀: /api/message

// 公告相关路由
Route::group('announcement', function () {
    // 获取公告列表
    Route::get('list', [AnnouncementController::class, 'getList']);
    // 获取公告详情
    Route::get('detail', [AnnouncementController::class, 'getDetail']);
})->middleware(['auth']);

// 通知相关路由
Route::group('notification', function () {
    // 获取通知列表
    Route::get('list', [NotificationController::class, 'getList']);
    // 获取通知详情
    Route::get('detail', [NotificationController::class, 'getDetail']);
    // 标记通知为已读
    Route::post('mark_read', [NotificationController::class, 'markAsRead']);
    // 批量标记通知为已读
    Route::post('batch_mark_read', [NotificationController::class, 'batchMarkAsRead']);
    // 标记所有通知为已读
    Route::post('mark_all_read', [NotificationController::class, 'markAllAsRead']);
    // 删除通知
    Route::post('delete', [NotificationController::class, 'delete']);
    // 批量删除通知
    Route::post('batch_delete', [NotificationController::class, 'batchDelete']);
    // 获取未读通知数量
    Route::get('unread_count', [NotificationController::class, 'getUnreadCount']);
})->middleware(['auth']);

// 私信相关路由
Route::group('private_message', function () {
    // 获取对话列表
    Route::get('conversation_list', [PrivateMessageController::class, 'getConversationList']);
    // 获取与指定用户的对话消息
    Route::get('conversation_messages', [PrivateMessageController::class, 'getConversationMessages']);
    // 发送私信
    Route::post('send', [PrivateMessageController::class, 'send']);
    // 标记私信为已读
    Route::post('mark_read', [PrivateMessageController::class, 'markAsRead']);
    // 标记与指定用户的所有私信为已读
    Route::post('mark_all_read', [PrivateMessageController::class, 'markAllAsRead']);
    // 删除私信
    Route::post('delete', [PrivateMessageController::class, 'delete']);
    // 删除与指定用户的所有对话
    Route::post('delete_conversation', [PrivateMessageController::class, 'deleteConversation']);
    // 获取未读私信数量
    Route::get('unread_count', [PrivateMessageController::class, 'getUnreadCount']);
})->middleware(['auth']);

// 消息设置相关路由
Route::group('setting', function () {
    // 获取用户消息设置
    Route::get('user', [MessageSettingController::class, 'getUserSetting']);
    // 更新用户消息设置
    Route::post('update', [MessageSettingController::class, 'updateSetting']);
})->middleware(['auth']);

// 获取消息列表
Route::resource('', MessageController::class)
    ->only(['index', 'read'])
    ->middleware(['auth', MacroPageMiddleware::class]);